package com.npjscg.medicalpro.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.npjscg.medicalpro.common.Constants;
import com.npjscg.medicalpro.common.Result;

import com.npjscg.medicalpro.entity.Notification;
import com.npjscg.medicalpro.service.INotificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author raote
 * @since 2022-06-29
 */
@Api(tags = "用户通知模块")
@RestController
@RequestMapping("/notification")
public class NotificationController {

    @Autowired
    private INotificationService notificationService;

    //需要用户id，is_check信息
    @ApiOperation(value = "分页查询用户的通知信息")
    @GetMapping("/findNotice/{pagenum}/{pagesize}/{uid}/{check}")
    public Result getInfo(@PathVariable int pagenum, @PathVariable int pagesize, @PathVariable int uid, @PathVariable int check){
        Page<Notification> page = new Page<>(pagenum,pagesize);

        return Result.success(notificationService.getInfo(page,uid,check));
    }

    //需要以post形式给前端
    @ApiOperation(value = "更改已读状态")
    @PostMapping("/change")
    public Result change(@RequestBody Notification notification){
        notificationService.change(notification);
        return Result.success();
    }

    //清空用户的已读信息
    @ApiOperation(value = "清空用户已读信息")
    @GetMapping("/empty/{uid}")
    public Result empty(@PathVariable int uid){
        notificationService.empty(uid);
        return Result.success();
    }

    @ApiOperation(value = "增加用户通知，暂时没啥用")
    @PostMapping("/addNotice")
    public Result addNotice(@RequestBody Notification notification){
        notificationService.addNotice(notification);
        return Result.success();
    }



}
